﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

using Ordinaire;
using Ordinaire.Db;
using Ordinaire.Commerce;
using Ordinaire.Commerce.Db;
using Ordinaire.Commerce.VendorRelation.Db;

using System.ComponentModel;

using System.Data.Linq;
using System.Reflection.Emit;
using System.Threading;

namespace Ordinaire.Commerce.VendorRelation.Test
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            // Setup test database
            SetupDb();

            string[] my_args = { Assembly.GetExecutingAssembly().Location, "/wait" };

            int returnCode = NUnit.ConsoleRunner.Runner.Main(my_args);

            if (returnCode != 0)
                Console.Beep();
        }

        /// <summary>
        /// Setup database for testing.
        /// </summary>
        static void SetupDb()
        {
            ExtensionContainer.Add(typeof(VendorRelationManager));
            ExtensionContainer.Add(
                @"C:\Users\jloe\Documents\Visual Studio 2010\Projects\Ordinaire\Ordinaire.Commerce.Purchasing\bin\Release"
            );

            DatabaseBuilder dbBuilder = new DatabaseBuilder();
            dbBuilder.Load();
            if (dbBuilder.DatabaseExists())
            {
                dbBuilder.DeleteDatabase();
            }
            dbBuilder.CreateDatabase();
        }
    }
}
